import { defineStore } from 'pinia';
import { dailyGood } from '@/services/apis';

export const useDailyGoodStore = defineStore('dailyGood', {
    state: () => ({
        dailyGoodList: []
    }),
    actions: {
        async list() {
            try {
                const pageSize = 16;
                const pageNum = 1;
                const isAsc = 'desc'
                this.dailyGoodList = await dailyGood.list({ pageSize, pageNum, isAsc});
            } catch (error) {
                return []
            }
        },

        async addOrModify(params: any) {
            return await dailyGood.addOrModify(params);
        },

        async findOne(params: any) {
            try {
                return await dailyGood.findOne(params);
            } catch (error) {
                return null
            }
        },
    }
})
